From: ssmith@weybridge.uk.xensource.com Date: Tue, 5 Sep 2006 13:27:05 +0000 (+0100) Subject: [XEN] Add more checking when reusing an active grant reference. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15668^2~18 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=9da69e0f6c13f02b84dd0f9a2be062c05b602141;p=xen.git [XEN] Add more checking when reusing an active grant reference. Signed-off-by: Steven Smith Based-on-a-patch-by: Herbert Xu --- diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index c8ba260711..95d36fce4e 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -175,12 +175,13 @@ __gnttab_map_grant_ref( spin_lock(&rd->grant_table->lock); + sdom = sha->domid; + if ( !act->pin || (!(op->flags & GNTMAP_readonly) && !(act->pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask))) ) { sflags = sha->flags; - sdom = sha->domid; /* * This loop attempts to set the access (reading/writing) flags @@ -235,6 +236,10 @@ __gnttab_map_grant_ref( act->frame = gmfn_to_mfn(rd, sha->frame); } } + else if ( unlikely(sdom != ld->domain_id) ) + PIN_FAIL(unlock_out, GNTST_general_error, + "Bad domain (%d). (NB. expected dom %d)\n", + sdom, ld->domain_id); else if ( (act->pin & 0x80808080U) != 0 ) PIN_FAIL(unlock_out, ENOSPC, "Risk of counter overflow %08x\n", act->pin); @@ -771,11 +776,12 @@ __acquire_grant_for_copy( spin_lock(&rd->grant_table->lock); + sdom = sha->domid; + if ( !act->pin || (!readonly && !(act->pin & GNTPIN_hstw_mask)) ) { sflags = sha->flags; - sdom = sha->domid; for ( ; ; ) { @@ -819,6 +825,10 @@ __acquire_grant_for_copy( act->frame = gmfn_to_mfn(rd, sha->frame); } } + else if ( unlikely(sdom != current->domain->domain_id) ) + PIN_FAIL(unlock_out, GNTST_general_error, + "Bad domain (%d). (NB. expected dom %d)\n", + sdom, current->domain->domain_id); else if ( (act->pin & 0x80808080U) != 0 ) PIN_FAIL(unlock_out, ENOSPC, "Risk of counter overflow %08x\n", act->pin);